package com.milk.service.order;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

import com.milk.model.entity.order.Order;
import com.milk.service.order.dao.OrderDao;

import org.springframework.stereotype.Service;

/**
 * order serviceImpl 2017-09-14 16:57:55 徐政涛
 */
@Service("orderService")
public class OrderServiceImpl implements OrderService {

	@Autowired
	private OrderDao orderDao;

	public Order save(Order order) {
		Assert.notNull(order, RESULT_NULL + "出错的方法体是saveOrder");
		orderDao.save(order);
		return order;
	}

	public Order update(Order order) throws Exception {
		Assert.notNull(order, RESULT_NULL + "出错的方法体是updateOrder");
		orderDao.update(order);
		return order;
	}

	public Order getOrderById(long orderId) {
		Order order = orderDao.findById(orderId);
		return order;
	}

	public void deleteOrderById(long orderId) {
		orderDao.deleteById(orderId);
	}

	public Order getOrderByMap(Map<String, Object> params) {
		Order order = orderDao.findByMap(params);
		return order;
	}

	public void deleteOrderByMap(Map<String, Object> params) {
		orderDao.deleteByMap(params);
	}

	public List<Order> queryOrder(Map<String, Object> params) {
		List<Order> orders = orderDao.query(params);
		return orders;
	}
}